from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class knowledge_base_fetcher_fake :
    def __init__ ( self ) :
        self . _knowledge_bases_fetched = False
        self . _list_knowledge_bases_reply = None
        self . _knowledge_base_creation_time_reply = None
        self . _knowledge_base_modification_time_reply = None
        self . _knowledge_base_size_reply = None
    def fetch_all_knowledge_bases ( self ) :
        self . _knowledge_bases_fetched = True
    def list_knowledge_bases_reply ( self , bases ) :
        self . _list_knowledge_bases_reply = bases
    def knowledge_base_creation_time_reply ( self , time ) :
        self . _knowledge_base_creation_time_reply = time
    def knowledge_base_modification_time_reply ( self , time ) :
        self . _knowledge_base_modification_time_reply = time
    def knowledge_base_size_reply ( self , size ) :
        self . _knowledge_base_size_reply = size

class mediator_knowledge_base_fetcher_tests : 
    'mediator_knowledge_base_fetcher'
    def __init__ ( self , test ) :
        self . _test = test
        self . _knowledge_base_fetcher = knowledge_base_fetcher_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'knowledge_base_fetcher' 
            , self . _knowledge_base_fetcher 
            , None
            ) )
    def test_fetch_all_knowledge_bases ( self ) :
        self . _mediator . fetch_all_knowledge_bases ( )
        self . _test . assume_true ( self . _knowledge_base_fetcher . _knowledge_bases_fetched )
    def test_list_knowledge_bases_reply ( self ) :
        self . _mediator . list_knowledge_bases_reply ( 'my bases' )
        self . _test . assume_equal ( self . _knowledge_base_fetcher . _list_knowledge_bases_reply , 'my bases' )
    def test_knowledge_base_creation_time_reply ( self ) :
        self . _mediator . knowledge_base_creation_time_reply ( 'my time' )
        self . _test . assume_equal ( self . _knowledge_base_fetcher . _knowledge_base_creation_time_reply , 'my time' )
    def test_knowledge_base_modification_time_reply ( self ) :
        self . _mediator . knowledge_base_modification_time_reply ( 'my time' )
        self . _test . assume_equal ( self . _knowledge_base_fetcher . _knowledge_base_modification_time_reply , 'my time' )
    def test_knowledge_base_size_reply ( self ) :
        self . _mediator . knowledge_base_size_reply ( 'my size' )
        self . _test . assume_equal ( self . _knowledge_base_fetcher . _knowledge_base_size_reply , 'my size' )
